#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
	int findPoisonedDuration(vector<int>& timeSeries, int duration) {
		int ret = 0;
		for (int i = 1; i < timeSeries.size(); i++)
		{
			int tmp = timeSeries[i] - timeSeries[i - 1];
			if (tmp >= duration) ret += duration;
			else ret += tmp;
		}
		return ret + duration;
	}
};